/*
自己选择的路 ,跪着也要走完。朋友们 , 虽然这个世界日益浮躁起来,只
要能够为了当时纯粹的梦想和感动坚持努力下去 , 不管其它人怎么样,我
们也能够保持自己的本色走下去。
To the world , you will be a person , but to a person , you
will be the world .                               ——AKPower
*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll maxn = 1e5 + 100;
struct node
{
    ll y, next_s;
} e[maxn * 2];
ll siz[maxn], z1, z2, n;
ll head[maxn], cnt;
void init()
{
    memset(head, -1, sizeof(head));
    cnt = 0;
    return;
}
void add(ll x, ll y)
{
    e[cnt].y = y;
    e[cnt].next_s = head[x];
    head[x] = cnt++;
    return;
}
ll n_pre;
void dfs_pre(ll u, ll f)
{
    n_pre++;
    for (ll i = head[u]; i != -1; i = e[i].next_s)
    {
        ll v = e[i].y;
        if (v == f)
            continue;
        dfs_pre(v, u);
    }
    return;
}
ll sum[maxn];
ll max_siz;
void dfs1(ll u, ll f, bool flag)
{
    siz[u] = 1;
    ll maxx = 0;
    for (ll i = head[u]; i != -1; i = e[i].next_s)
    {
        ll v = e[i].y;
        if (v == f)
            continue;
        dfs1(v, u, flag);
        siz[u] += siz[v];
        maxx = max(maxx, siz[v]);
    }
    ll minn;
    if (flag)
    {
        minn = max(maxx, n_pre - siz[u]);
    }
    else
    {
        minn = max(maxx, n - n_pre - siz[u]);
    }
    if (max_siz > minn)
    {
        if (flag)
        {
            z1 = u;
        }
        else
        {
            z2 = u;
        }
        max_siz = minn;
    }
    return;
}
ll ans;

void dfs2(ll u, ll f)
{
    siz[u] = 1;
    sum[u] = 0;
    for (ll i = head[u]; i != -1; i = e[i].next_s)
    {
        ll v = e[i].y;
        if (v == f)
            continue;
        dfs2(v, u);
        // ans+=siz[v]*(sum[u]+siz[u]);
        sum[u] += sum[v] + siz[v];
        siz[u] += siz[v];
    }
    for (ll i = head[u]; i != -1; i = e[i].next_s)
    {
        ll v = e[i].y;
        if (v == f)
            continue;
        ans += siz[v] * (sum[u] - sum[v] - siz[v]);
        // ans += sum[u];
    }
    ans += sum[u];
    return;
}

int main()
{
    IOS;
    init();
    ll x, y;
    cin >> n;
    for (ll i = 1; i <= n - 2; i++)
    {
        cin >> x >> y;
        add(x, y);
        add(y, x);
    }
    dfs_pre(1, -1);
    max_siz = INF;
    dfs1(1, -1, true);
    max_siz = INF;
    for (ll i = 1; i <= n; i++)
    {
        if (siz[i])
            continue;
        dfs1(i, -1, false);
        break;
    }
    ans = 0;
    dfs2(z1, -1);
    dfs2(z2, -1);
    //cout << ans << endl;
    ans += (siz[z1]) * (sum[z2] + siz[z2]);
    ans += siz[z2] * (sum[z1]);
    cout << ans << endl;
    getchar();
    getchar();
    return 0;
}